/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

/**
 * @version thread.h 0.0.1
 * @package Comoro
 * @author Dr.NP <np@bsgroup.org>
 * 
 * Multi-thread operator header
 */

#include <pthread.h>
#include <event.h>

#define WORKER_POOL_SIZE						256
#define WORKER_TYPE_CONN						1
#define WORKER_TYPE_COIN						2

#define WORKER_DISPATCH_ALL					0
#define WORKER_DISPATCH_CHILD_ONLY			1
#define WORKER_DISPATCH_MAIN_ONLY			2

struct thread_worker
{
	int id;
	pthread_t tid;
	struct event_base *ev_base;
	struct event ev_notify;
	int notify_recv_fd;
	int notify_send_fd;
};

/* BEGIN OF FUNCTION DEFINE*/
int thread_init								();
int thread_worker_new						(int);
void * thread_worker_init					(void *);
void thread_worker_process					(int, short, void *);
int thread_worker_dispatch					(char, int, char);
int thread_list_find_free					();
int thread_list_find_next					();
/* END OF FUNCTION DEFINE */
